/**
 * @fileOverview 文档辅助脚本
 * @author: simonsliu
 * @date: 11-11-26 - 下午2:19
 */
document.addEventListener('DOMContentLoaded', function() {
	var btnRunCode = document.querySelectorAll('.btn-run-code'),
		btn, i, j, len, sublen;
	for ( i = 0, len = btnRunCode.length; i < len; i++ ) {
		btn = btnRunCode[ i ];
		var codeBlocks = btn.dataset['code'].split(' '), codeBlock, code = '';
		for ( j = 0, sublen = codeBlocks.length; j < sublen; j++ ) {
			codeBlock = document.getElementById( codeBlocks[ j ] );
			code += codeBlock.innerText;
		}
		(function( c ) {
			btn.addEventListener('click', function() {
				eval( c );
			});
		})( code )
	}
}, false)